<%@ Page Language="C#" EnableViewState="false" ValidateRequest="false" AutoEventWireup="true" Inherits="Syrinx.Gui.AspNet.Nitobi2.NitobiBasePage" 
	MasterPageFile="~/App_ThemeMasters/NoStyle/AdminOneColumnLayout.Master" %>

<%@ Register Assembly="Swaf.Gui.AspNet2" Namespace="Swaf.Gui.AspNet2" TagPrefix="swf" %>
<%@ Register Assembly="ScsAspNet" Namespace="Syrinx.Gui.AspNet.Nitobi2" TagPrefix="snc" %><%@ Register Assembly="NitobiControls" Namespace="Nitobi" TagPrefix="ntb" %>

<!--#include file="~/SiteControls/RegisterStandardControls.txt"-->
<!--#include file="../SiteControls/StandardHeaderPageContent.inc"-->
<!--#include file="../SiteControls/StandardFooterPageContent.inc"-->

<script runat="server">
	public string TitleFormat = "$company.name$ Product Management";
</script>

<asp:Content ContentPlaceHolderID="title" runat="server" ID="c1">
	<%SecurityPrivilege = "AppFunctions.ManageProducts"; %>
	<div class="adminHeader"><h1><asp:Label runat="server" ID="currencyConvertLbl" >Product Management</asp:Label></h1></div>
	<div class="HelpBtnArea" style="float:right">
		<asp:HyperLink runat="server" ID="_pageHelp" NavigateUrl="../std/Help.aspx?helpid=ProductManagementHelp" Target="help">Help</asp:HyperLink>
	</div>
	<swf:BizProc ID="sArt1" runat="server" factoryName="eComProducts">
		<State pid="" includeSelf="true" entireTree="true" EditModeSessionKey="GlobalEdit" />
		<ParentBizProc id="loginBP" />
	</swf:BizProc>
	<swf:BizProc ID="prodTax" runat="server" factoryName="eComProductTaxes" >
		<ParentBizProc id="sArt1" fieldName="id" dataId="pid" />
	</swf:BizProc>
	<swf:BizProc ID="prodDisc" runat="server" factoryName="eComProductQuantityDiscounts" >
		<ParentBizProc id="sArt1" fieldName="id" dataId="pid" />
	</swf:BizProc>
</asp:Content>

<asp:Content ContentPlaceHolderID="mainContent" runat="server" ID="c3">
<script>
function DivResizer(div,resizer){
	this.resizer = resizer;
	this.div=div;
	this.box=document.getElementById("ebagridresizebox_");
	if(this.box==null){
	this.box=document.createElement("div");
	this.box.id="ebagridresizebox_";
	document.body.appendChild(this.box);
	this.box.className="ntbcolumnresizeline";
	}
}

DivResizer.prototype.startResize=function(evt){
//debugger;
var _2cb=null;
var x,y;
var _2ce=nitobi.html.getEventCoords(evt);
x=evt.offsetX;//_2ce.x;
y=evt.offsetY;//_2ce.y;
this.x=_2ce.x;//x;
this.y=_2ce.y;
var w=this.div.style.pixelWidth;
var h=this.div.style.pixelHeight;
var L=0;//this.div.offsetLeft;
var T=0;//this.div.offsetTop;
this.resizeW=(Math.abs((x-L)-w)<3)||((Math.abs((y-T)-h)<16)&&(Math.abs((x-L)-w)<16));
this.resizeH=(Math.abs((y-T)-h)<3)||((Math.abs((y-T)-h)<16)&&(Math.abs((x-L)-w)<16));
if(this.resizeW||this.resizeH){
this.box.style.cursor=(this.resizeW&&this.resizeH)?"NW-Resize":(this.resizeW)?"W-Resize":"N-Resize";
this.box.style.visibility="visible";
this.box.style.width=(x-L)+"px";
this.box.style.height=(y-T)+"px";
var _2d3=nitobi.drawing.align.SAMEWIDTH|nitobi.drawing.align.SAMEHEIGHT|nitobi.drawing.align.ALIGNTOP|nitobi.drawing.align.ALIGNLEFT;
nitobi.drawing.align(this.box,this.div,_2d3,0,0,0,0,false);
this.dd=new nitobi.ui.DragDrop(this.box,false,false);
this.dd.onDragStop.subscribe(this.endResize,this);
this.dd.onMouseMove.subscribe(this.resize,this);
this.dd.startDrag(evt);
}
};

DivResizer.prototype.resize=function(){
//debugger;
var x=this.dd.x;
var y=this.dd.y;
var L=this.div.offsetLeft;
var T=this.div.offsetTop;
this.box.style.visibility="visible";
if(this.resizeW){
this.div.innerHtml = "x = " + x + " : this.x = " + this.x + " : box.pixelWidth = " + this.box.style.pixelWidth;
this.box.style.width= this.div.style.pixelWidth + (x-this.x)+"px";
}
if(this.resizeH){
this.box.style.height=this.div.style.pixelHeight + (y-this.y)+"px";
}
};

DivResizer.prototype.endResize=function(){
var x=this.dd.x;
var y=this.dd.y;
this.box.style.visibility="hidden";
var _2da=this.div.style.pixelWidth;
var _2db=this.div.style.pixelHeight;
var _2dc=parseInt(_2da)+((this.resizeW)?x-this.x:0);
var _2dd=parseInt(_2db)+((this.resizeH)?y-this.y:0);
if(isNaN(_2dc)||isNaN(_2dd)){
return;
}
if(_2dc>20&&_2dd>20){
debugger;
this.div.style.width = _2dc + "px";
this.div.style.height = _2dd + "px";
var base = document.getElementById("ctl00_d0_mainContent_ad1_d2_baseBody_toolbarArea").parentElement;
var tbHeight = base.children[0].offsetHeight;
var tabHeight = base.children[4].offsetHeight
//this.resizer.style.height = (_2dd - tbHeight - tabHeight - 20) + "px";//this.resizer.offsetHeight + (y - this.y) + "px";
this.resizer.style.height = this.resizer.offsetHeight + (y - this.y) + "px";
}
};

DivResizer.prototype.dispose=function(){
this.grid=null;
};
function setupSizer()
{
sr = new DivResizer(document.getElementById("sizeArea"),document.getElementById("ctl00_d0_mainContent_ad1_d2_baseBody_designEditor"))
}
var sr = null;
function start(item)
{
if(sr == null)
	setupSizer();
sr.startResize(window.event);
}
</script>
<script type="text/javascript">
function toggleTabs(cId,c1, dId){
	for(i=1; ;i++){
		var a = document.getElementById(cId + i);
		var b = document.getElementById(dId + i);
		if(a==null || a=='')
			break;
			
		if(i==c1){
			a.className = 'currenttab';
			b.style.display = 'block';
		}
		else{
			a.className='';
			b.style.display = 'none';
		}
	}
}
</script>

    <span class="button4"><snc:ActionButton runat="server" ID="editMode" Actions="sArt1.SwitchEdit" Text="Edit" SessionBoolSwitch="GlobalEdit" /></span>
    <span class="button1"><snc:ActionButton runat="server" ID="addBtn" Actions="sArt1.AddBizObj" Text="Add" /></span>
    <span class="button6"><snc:ActionButton runat="server" ID="updateBtn" Actions="sArt1.UpdateBizObj,prodDisc.UpdateBizObj,prodTax.UpdateBizObj" Text="Update" /></span>
    <span class="button1"><snc:ActionButton runat="server" ID="cancelBtn" Actions="sArt1.CancelEdits" Text="Cancel" /></span>
    <span class="button5"><snc:ActionButton runat="server" ID="deleteBtn" Actions="sArt1.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;" /></span>
    <span class="button1"><snc:ActionButton runat="server" ID="setPicBtn" Actions="sArt1.SetArticlePicture" Text="Set Image" 
        PopupPage="../popups/SetArticleImagePopup.aspx" PopupHeight="650px" PopupWidth="800px" PopupTitle="Select a primary image for this product." /></span>
    <span class="button1"><snc:ActionButton runat="server" ID="generateBtn" Actions="sArt1.GenerateFromMedia" Text="Generate From Media" 
        PopupPage="../popups/ImageArticleGenPopup.aspx" PopupHeight="650px" PopupWidth="800px" PopupTitle="Generate products from media directory." /></span>
    <span class="button1"><snc:ActionButton runat="server" ID="assocBtn" Actions="sArt1.SetAsChildArticle" Text="Associate Article" 
        PopupPage="../std/ArticleAssociationPopup.aspx" PopupHeight="650px" PopupWidth="800px" PopupTitle="Associate an article to this product." /></span>

	<table width="adminPageWidth"><tr><td>
    <div class="verticalbg"> 
        <snc:Grid ID="articleList1Display" runat="server" Width="350px" Height="600px"  
	        ShowToolbar="false" Resizable="Both" ParentBizProcIds="sArt1" Mode="LiveScrolling">
	        <Columns>
		        <ntb:KeyColumn DataField="id" />
		        <ntb:BoundColumn DataField="depthName" HeaderText="Name" width="330" />
	        </Columns>
        </snc:Grid>
    </div>
</td><td class="adminRightContentWidth">
        <div class="horizontalbg">
			<div class="clearer"></div>
			<div class="tabs" style="padding-left:10px; padding-right:10px;">
				<ul>
					<li id="t1" class="currenttab"><div class="firstTab"><swf:DivLayers runat="server" ID="tl1" SkinID="Tab"><asp:HyperLink onclick="toggleTabs('t','1','xfd');" runat="server" ID="_cmpMngrTab1" Text="Product Description" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
					<li id="t2"><div class="lastTab"><swf:DivLayers runat="server" ID="tl4" SkinID="Tab"><asp:HyperLink runat="server" onclick="toggleTabs('t','2','xfd');" ID="_cmpMngrTab2" Text="Product Details" NavigateUrl="javascript:;" /></swf:DivLayers></div></li>
				</ul>
			</div>
			<div class="clearer"></div>
			<swf:DivLayers ID="mdl1" runat="server" SkinID="MainTabArea">
				<div id="xfd1">
					<snc:NitobiBizObjDisplay ID="ad1" runat="server" 
						ReadOnlyTemplate="eCom.Gui.AspNet.ProductRODisplay" 
						EditableTemplate="eCom.Gui.AspNet.ProductRWDisplay-NEW" 
						ParentBizProcIds="sArt1" >
							<macros>
								<Entry name="navLink" type="String">../std/ArticleView.aspx?gArt1pid=$pid$&amp;gArt1id=$id$</Entry>
								<Entry name="imageRes" type="String">Thumbnail</Entry>
							</macros>
					</snc:NitobiBizObjDisplay>
				</div>
				<div id="xfd2" style="display:none">
					<snc:NitobiBizObjDisplay ID="ad2" runat="server" 
						ReadOnlyTemplate="eCom.Gui.AspNet.ProductDetailsROView" 
						EditableTemplate="eCom.Gui.AspNet.ProductDetailsRWView" 
						ParentBizProcIds="sArt1" >
							<macros>
								<Entry name="navLink" type="String">../std/ArticleView.aspx?gArt1pid=$pid$&amp;gArt1id=$id$</Entry>
								<Entry name="imageRes" type="String">Thumbnail</Entry>
							</macros>
					</snc:NitobiBizObjDisplay>
					<h3><asp:Label runat="server" ID="_tax">Product Taxes</asp:Label></h3>
					<snc:ComplexBizObjListDisplay ID="pt1" runat="server" ParentBizProcIds="prodTax"
						ReadOnlyTemplate="eCom.Gui.AspNet.ProductTaxListDisplay"  >
					</snc:ComplexBizObjListDisplay>		
					<h3><asp:Label runat="server" ID="_qP">Quantity Price Discounts</asp:Label></h3>
					<snc:ComplexBizObjListDisplay ID="pq1" runat="server" ParentBizProcIds="prodDisc"
						ReadOnlyTemplate="eCom.Gui.AspNet.ProductQuantityDiscountListDisplay"  >
					</snc:ComplexBizObjListDisplay>		
				 </div>  
				</swf:DivLayers>
         </div>
         <div class="clearer"></div>
        <span class="button6"><snc:ActionButton runat="server" ID="ActionButton1" Actions="sArt1.UpdateBizObj,prodDisc.UpdateBizObj,prodTax.UpdateBizObj" Text="Update" /></span>
</td></tr></table>    
</asp:Content>
